package com.zh.device.util;

import com.zh.common.utils.StringUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DeviceUtil {

    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**
     * 格式化接收时间
     * @param tdate
     * @return
     */
    public static String formatCreateDate(String tdate) throws Exception{
        if (StringUtil.isEmpty(tdate)) return null;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        Date date = formatter.parse(tdate);
        return simpleDateFormat.format(date);
    }


    /**
     * 格式化接收时间
     * @param tdate
     * @return
     */
    public static Date formatCreateByDate(String tdate) throws Exception{
        if (StringUtil.isEmpty(tdate)) return null;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        return formatter.parse(tdate);
    }
}
